package org.evil.dog.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.evil.dog.dto.user.login.req.ReqUserLoginDto;
import org.evil.dog.dto.user.login.res.ResUserLoginDto;
import org.evil.dog.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/user")
@Api(value = "用户登登出",tags = "user-login-api")
public class UserLoginController extends AbstractController {

    @Autowired
    private UserLoginService userLoginService;

    @ApiOperation(value = "登录/注册", notes = "用户使用验证码进行登录或者注册", response = ResUserLoginDto.class)
    @RequestMapping(value = "/loginOrReg", method = RequestMethod.POST)
    public Object loginOrReg(@RequestBody ReqUserLoginDto reqUserLoginDto,
                             HttpServletRequest request,
                             HttpServletResponse response) {
        //验证需要
        //ReqHeadInfo reqHeadInfo = this.getHead(request);
        ResUserLoginDto resUserLoginDto = new ResUserLoginDto();
        resUserLoginDto.setToken("ahahahhh11111111223202365462");
        resUserLoginDto.setUserLogType(1);
        /*try {
            resLoginDto = iLoginService.loginOrReg(loginOrRegDto, reqHeadInfo);
        } catch (ZoomAppException e) {
            response.setStatus(e.getCode());
            return e.getMsg();
        }*/
        return resUserLoginDto;
    }
}
